#region license
# This file is part of Grawlix.
# 
# Grawlix is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as
# published by the Free Software Foundation, either version 3 of
# the License, or (at your option) any later version.
# 
# Grawlix is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.
# 
# You should have received a copy of the GNU General Public
# License along with Grawlix.  If not, see
# <http://www.gnu.org/licenses/>.
#endregion

"""An IEnvironmentFactory that spawns a new AppDomainEnvironment."""

namespace Grawlix.Services
import System

final transient class AppDomainEnvironmentFactory(
	ServiceBase,
	IEnvironmentFactory):
"""A factory which spawns AppDomainEnvironments."""
	
	def constructor(
		[required] basePath as string,
		[required] searchPaths as string):
	"""
	Initializes a new factory.
	Param basePath: The root appdomain directory.
	Param searchPaths: A semicolon-separated list of root
		directories to search for assemblies.
	"""
		_basePath = basePath
		_searchPaths = searchPaths
	
	def Create([required] name as string):
	"""
	Creates a new AppDomainEnvironment.
	Param name: The name of the new environment.
	Returns: The new AppDomainEnvironment.
	"""
		return AppDomainEnvironment(name, _basePath, _searchPaths, true)
		
	override def ToString():
	"""
	Get a string representation for this object.
	Returns: A string representation for this object.
	"""
		return "AppDomainEnvironmentFactory ${BasePath} ${SearchPaths}"
	
	[getter(BasePath)]
	private _basePath as string
	"""The root appdomain directory."""
	
	[getter(SearchPaths)]
	private _searchPaths as string
	"""Directories specifying where to search for assemblies."""
	
